const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('option', {
    option_field: {
      type: DataTypes.STRING(10),
      allowNull: false,
      primaryKey: true,
      comment: "选项字段(ABCD)"
    },
    exercise_id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true,
      references: {
        model: 'exercises',
        key: 'exercises_id'
      }
    },
    option_content: {
      type: DataTypes.STRING(100),
      allowNull: true
    }
  }, {
    sequelize,
    tableName: 'option',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "option_field" },
          { name: "exercise_id" },
        ]
      },
      {
        name: "exercise_id",
        using: "BTREE",
        fields: [
          { name: "exercise_id" },
        ]
      },
    ]
  });
};
